<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb>
      <el-breadcrumb-item>共同表录入</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 表单输入 -->
    <div class="TFormBox">
      <el-form ref="TFormRef" :model="TForm" :rules="TFormRules" class="TForm_sty">
        <el-form-item prop="t_gid">
          <el-input v-model="TForm.gid">
            <template slot="prepend">组ID</template>
          </el-input>
        </el-form-item>
        <el-form-item prop="t_type">
          <el-input v-model="TForm.type">
            <template slot="prepend">组名称</template>
          </el-input>
        </el-form-item>
        <el-form-item prop="t_sid">
          <el-input v-model="TForm.sid">
            <template slot="prepend">分ID</template>
          </el-input>
        </el-form-item>
        <el-form-item prop="t_name">
          <el-input v-model="TForm.name">
            <template slot="prepend">分享名称</template>
          </el-input>
        </el-form-item>
        <el-form-item class="btns">
          <el-button type="primary" @click="inserUser" round>录入</el-button>
          <el-button type="info" @click="resetConnectionForm" round>重置</el-button>
        </el-form-item>
      </el-form>
      <!-- 提交弹窗 -->
      <el-dialog title="提示" :visible.sync="sucessVisible" width="30%">
        <span>确定录入？</span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="sucessVisible = false">取 消</el-button>
          <el-button type="primary" @click="sucessVisible = false">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      TForm: {
        gid: '',
        type: '',
        sid: '',
        name: ''
      },
      // 输入规则
      TFormRules: {
        gid: [
          { required: true, message: '请输入组ID', trigger: 'blur' }
        ],
        tyep: [
          { required: true, message: '请输入组名称', trigger: 'blur' }
        ],
        sid: [
          { required: true, message: '请输入分ID', trigger: 'blur' }
        ],
        name: [
          { required: true, message: '请输入分项名称', trigger: 'blur' }
        ]
      },
      sucessVisible: false
    }
  },
  methods: {
    // 校验规则
    resetTForm() {
      this.$refs.TFormRef.resetFields()
    },
    // 提交用户
    inserUser() {
      const { data: res } = this.$http.post('together', {
        t_gid: this.TForm.gid,
        t_type: this.TForm.type,
        t_sid: this.TForm.sid,
        t_name: this.TForm.name
      })
      this.emidtsucess()
      console.log(res)
    },
    // 提交成功提示
    emidtsucess() {
      this.sucessVisible = true
    }
  }
}
</script>

<style lang="less" scoped>
.el-form-item {
  width: 500px;
}

.ConnectionFormBox {
  background-color: #fffffb;
  height: 600px;
  width: 1210px;
  border-radius: 5px;
  margin-left: 10px;
}

.ConnectionForm_sty {
  position: absolute;
  padding: 30px 60px 30px;
  box-sizing: border-box;
}

.btns {
  display: flex;
  justify-content: flex-start;
  margin-top: 60px;
}
</style>
